/*
 * 〈描述〉
 *
 * @author Think
 * @since 版本号
 */

package com.duyj;


import java.math.BigDecimal;
import java.math.RoundingMode;

public class Utils {


    public static void timeLog(String msg, int count, Runnable supplier) {
        long s = System.currentTimeMillis();
        supplier.run();
        long init = System.currentTimeMillis() - s;

        long s1 = System.currentTimeMillis();
        for (int j = 0; j < count; j++) {
            supplier.run();
        }
        long sum = System.currentTimeMillis() - s1;
        double per = BigDecimal.valueOf(sum).divide(BigDecimal.valueOf(count), 2, RoundingMode.HALF_DOWN).doubleValue();
        System.out.printf("--->%s count:%s \tinit:%sms \tsum:%sms \tper:%sms %n", msg, count, init, sum, per);
    }

}
